<template>
  <div class="container-y">
    <bodyWrap :isShow="bodyShow">
      <div slot="body" v-if="bodyShow">

        <!--<template-items-->
          <!--v-for="(item,index) in feedBackDetails"-->
          <!--:key="index"-->
          <!--:title="item.title"-->
          <!--:list="item.list">-->
        <!--</template-items>-->

        <div class="advice-wrap">
          <div class="title"></div>
          <div class="content">
            <div class="item" v-for="item in feedBackDetails">
              <div class="top">
                {{item.operator}}
                <!--<phone-call :item="item"></phone-call>-->
                <br/>
                {{item.time}}
              </div>
              <pre class="txt" v-html="item.content"></pre>
            </div>
          </div>
        </div>

      </div>
    </bodyWrap>
  </div>
</template>

<script>
  import templateItems from "../commonComponents/templateItems.vue"

  export default {
    data() {
      return {
        bodyShow: false,
        feedBackDetails: []
      }
    },
    methods: {
      init() {
        this.headerFlag = this.$store.state.showFlag;
        _methods.headerTitleChange(140);
        this.feedBackHistoryListGet();
      },
      //流转详情获取
      feedBackHistoryListGet() {
        _ajax.noLoading(_ajaxUrls.feedBackHistory.url,
          {fId: _data.feedBackHistoryID},
          (ajData) => {
            let data = ajData.result;
            if (data.length) {
              let al = {
                1: "应对情况",
                3: "反馈情况",
                2: "协调处置反馈",
              }[_data.feedBackHistoryType];
              let lb = {
                1: "应对要求",
                2: "协调处置要求",
                3: "反馈要求",
              }[_data.feedBackHistoryType];
              data = data.map(i => {
                try {
                  let list = JSON.parse(i.content);
                  let response = `${al}： ${list.response}\n`;
                  list = JSON.parse(list.attributeBeanJSON);
                  i.content = response;
                  list.forEach(ii=>{
                    i.content = i.content + `${ii.label}： ${ii.attributesValue}\n`
                  });
                }
                catch (e) {
                  i.content = `${lb}： ${i.content}`;
                }
                return i;
              });
              this.feedBackDetails = data;
            } else {
              _alert.alert(() => {
                _methods.goBack();
              }, "暂无记录");
            }
            this.bodyShow = true;
          },
          _ajaxUrls.feedBackHistory.type);
      },
    },
    created() {
      this.init();
    },
    components: {
      templateItems,
    },
    beforeDestroy() {
      _methods.headerTitleChange(this.headerFlag, true);
    }
  }
</script>
